<%-- 
    Document   : index
    Created on : Apr 7, 2011, 10:56:34 PM
    Author     : Dawn
--%>

<%@page import="progin.java.User"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>

<jsp:useBean id="users" class="Session.SessionKeeper" scope="session"></jsp:useBean>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Chatrena</title>
        <script type="text/javascript" language="JavaScript" src="util-functions.js"></script>
        <script type="text/javascript" language="JavaScript" src="clear-default-text.js"></script>
        <link rel="StyleSheet" href="CSS/MenuStyle.css" type="text/css" />
    </head>
    <body>
        <%
            if (session != null ) {
                User user = (User)session.getAttribute("usr");

                if (user != null) {
                    if (user.getRole() == 0) {
                        response.sendRedirect("Admin");
                    }
                    else if (user.getRole() == 1) {
                        response.sendRedirect("Chat.jsp?Username=" + user.getUsername());
                    }
                    else if (user.getRole() == 2) {
                        response.sendRedirect("Chat.jsp?Username=" + user.getUsername());
                    }
                }
            }
        %>
        <div id="sidebar">
            <h1>Chit-Chat</h1>
            <h2>Tubes 4 Progin</h2>

            <p>
                Created by :<br /><br />
                Archie Anugrah - 13508001<br />
                Darwin Soesanto - 13508102<br />
                Listiarso Wastuargo - 13508103<br />
            </p>

            <div id="menu">
                <a class="active" href="#">Home</a>
            </div>
        </div>



        <div id="content">
            <h3>Login</h3>
            <%
                String error = request.getParameter("s");
                if (error != null)
                {
                    if (error.equals("1"))
                        out.println("Invalid login. Please input the correct one.");
                    if (error.equals("8080"))
                        out.println("The user has been blocked by the administrator.");
                }
            %>
            <div id="loginarea" align="right">
                <form action="LoginProcess" id="Login">
                    Username : <input type="text" name="Login_Username" class="input">
                    Password : <input type="password" name="Login_Password" class="input">
                    <input type="submit" value="Login">
                </form>
            </div>

            <h2></h2>
            <h3>Registration</h3>
            <%
                if (error != null)
                {
                    if (error.equals("2"))
                        out.println("Registration succeed !!!");
                    else if (error.equals("3"))
                        out.println("Registration failure. Please try again. Sorry for the inconvenience.");
                    else if (error.equals("999"))
                        out.println("Please match both of the password.");
                }
            %>
            <div id="loginarea">
                <form action="Registration" id="Registration">
                    <p>Name<input id="name" name="Name" type="text" size="50" style="float:right;" /></p>
                    <p>UserName<input id="username" name="Username" type="text" size="50" style="float:right;" /></p>
                    <p>Password<input id="password" name="Password" type="password" size="25" maxlength="25" style="float:right;" /></p>
                    <p>Confirm Password<input id="confirmpassword" name="ConfirmPassword" type="password" size="25" maxlength="25" style="float:right;" /></p>
                    <p>E-Mail<input id="email" name="EMail" type="text" size="50" style="float:right;" /></p>
                    <p> <input id="submitSignup" name="Submit" type="submit" value="SignUp" style="float:right;" </p>
                </form>

            </div>
        </div>
    </body>
</html>
